package com.bw.module_parking.view

import android.content.Intent
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.lib_base.path.RouterPath
import com.bw.lib_base.view.BaseActivity
import com.bw.module_parking.R
import com.bw.module_parking.adpter.ParkingAdapter
import com.bw.module_parking.databinding.ActivityParkingBinding
import com.bw.module_parking.viewModel.ParkingViewModel
import dagger.hilt.android.AndroidEntryPoint
/**
 * 智慧园区-02-车位管理-v1.1-曲烨-20250509
 */
@Route(path = RouterPath.PATH_PARKING_ACTIVITY)
@AndroidEntryPoint
class ParkingActivity : BaseActivity<ActivityParkingBinding>() {

    private val vm by lazy { ViewModelProvider(this)[ParkingViewModel::class.java] }

    private lateinit var parkingAdapter: ParkingAdapter
    override fun initView() {
        super.initView()
        parkingAdapter = ParkingAdapter()
        mDataBinding.parkingRv.layoutManager = LinearLayoutManager(this)
        vm.getParking(1)
        vm.getParkingSuccess.observe(this){
            parkingAdapter.data.addAll(it)
            mDataBinding.parkingRv.adapter = parkingAdapter
            parkingAdapter.notifyDataSetChanged()
        }

        mDataBinding.parkingAdd.setOnClickListener {
            startActivity(Intent(this,AddParkingActivity::class.java))
        }

        mDataBinding.back.setOnClickListener {
            finish()
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_parking
    }

}